home *** CD-ROM | disk | FTP | other *** search
/ Freelog 46 / Freelog046.iso / Alu / Celestia / Win32LoresTex / celestia-lores-win32-1.3.0.exe / {app} / shaders / rings.vp < prev    next >
Text File  |  2002-09-13  |  2KB  |  63 lines

  1. !!VP1.0
  2.  
  3. # Compute ring illumination.  Assumes rings made of spherical particles,
  4. # and no occlusion or shadowing between ring particles.  We also compute the
  5. # texture coordinates for the projected shadow of a planet.
  6.  
  7. # c[0]..c[3] contains the concatenation of the modelview and projection matrices.
  8. # c[4]..c[7] contains the inverse transpose of the modelview
  9. # c[15] contains the eye position in object space
  10. # c[16] contains the light direction in object space
  11. # c[17] contains H, the normalized sum of the eye and light direction
  12. # c[20] contains the object color * light color
  13. # c[32] contains the ambient light color
  14. # c[33] contains the haze color
  15. # c[34] contains the specular color * light color
  16. # c[41] and c[42] contain the shadow projection matrix
  17. # c[40] contains (0, 1, 0, specPower)
  18. # c[90] contains (0, 0.5, 1, 0)
  19. # v[OPOS] contains the per-vertex position
  20. # v[NRML] contains the per-vertex normal
  21. # v[TEX0] contains the per-vertex texture coordinate 0
  22. # o[HPOS] output register for homogeneous position
  23. # o[TEX0] output register for texture coordinate 0
  24. # o[COL0] output register for primary color
  25. # R0...R11 temporary registers
  26.  
  27. # Transform the vertex by the modelview matrix
  28. DP4   R1.x, c[0], v[OPOS];
  29. DP4   R1.y, c[1], v[OPOS];
  30. DP4   R1.z, c[2], v[OPOS];
  31. DP4   R1.w, c[3], v[OPOS];
  32.  
  33. # Get the vector from the eye to the vertex
  34. ADD   R4, c[15], -v[OPOS];
  35.  
  36. # Normalize it
  37. DP3   R0.w, R4, R4;
  38. RSQ   R0.w, R0.w;
  39. MUL   R4.xyz, R4, R0.w;
  40.  
  41. # Compute the illumination
  42. DP3   R2.x, R4, c[16];
  43. ADD   R2.x, R2.x, c[90].z;
  44. MUL   R2.x, R2.x, c[90].y;
  45.  
  46. # Output the primary color
  47. MOV   R0, c[32];
  48. MAD   o[COL0], c[20], R2.xxxx, R0;
  49.  
  50. # Output the texture
  51. MOV   o[TEX0], v[TEX0];
  52. # MOV   o[TEX1], v[TEX1];
  53.  
  54. # The second texture is the shadow; we need to compute the
  55. # it from the vertex coordinate.
  56. DP4   o[TEX1].x, c[41], v[OPOS];
  57. DP4   o[TEX1].y, c[42], v[OPOS];
  58.  
  59. # Output the vertex
  60. MOV   o[HPOS], R1;
  61.  
  62. END
  63.